
function showCurDateTime(){
	var myDate = new Date();
	var curDateTime = '今天是'+ myDate.getFullYear()+'年'+(myDate.getMonth()+1)+'月'+myDate.getDate()+'日';
	$("#curDateTime").html(curDateTime);	
}

function goIndex(){
	window.parent.location.href = "../index.html";
}

//控制头部选中的菜单栏显示
function showTabCur(){
    var tabIndex = getQueryString('tabIndex');
	if(tabIndex!=undefined && tabIndex!='' && tabIndex!=null){
		$(".menu_item").removeClass("cur");
		$(".menu_item").eq(tabIndex).addClass("cur");
	}else{
		$(".menu_item").removeClass("cur");
		$(".menu_item").eq(0).addClass("cur");
	}	
}

jQuery(document).ready(function(){
	
		showCurDateTime();
	
		showTabCur();
		
		$("#yuyue").click(function(){
			$.ajax({
				  type: 'POST',
				  url: '../user/getUser.do',
				  contentType : 'application/json',
				  data:JSON.stringify({}),
				  dataType: 'json',
				  success: function(data){
					  console.log(data)
					  if(data.result=="0"){
						  $.alert('请先登录');
					  }else{
						  window.parent.location.href=basePath()+'reserve/reserve/index.html';
					  }
				  }
			})
			
		})
		$("#frist").click(function(){
			window.parent.location.href=basePath()+'html/index.html?tabIndex=0';
		})
		$("#zhengwu").click(function(){
			window.parent.location.href=basePath()+'declareflow/declare/index.html?tabIndex=1';
		})	
		$("#shenbao").click(function(){
			alert("开发中")
		})
		$("#beian").click(function(){
			alert("开发中")
		})
		$("#zixun").click(function(){
			window.parent.open(basePath()+'repository/question/smart/smart.html?tabIndex=4');
		})

		$.ajax({
			type:'POST',
			async:false,
			url:'../user/validate',
			dataType:'json',
			success:function(data){
				if(1==data.result){
					$('#logined').css("display","block");
					$('#login').css("display","none");
					$('#logined dd:eq(0)').text(data.datas.userName+"欢迎登陆");
				}else{
					$('#logined').css("display","none");
					$('#login').css("display","block");
				}
			}
		});
		

	
		$("#logout").click(function(){
			$.ajax({
				type:'POST',
				async:false,
				url:'../user/logout',
				dataType:'json',
				success:function(data){
					$('#logined').css("display","none");
					$('#login').css("display","block");
				}
			})
		});
		
		
		
		$('.btn_login').click(function(){
			var userId = $(".selectpicker").val();
			var companyId ="91320118";
			var proposer = "赵四";
			var contactAddr = "南京";
			var telePhone = "90212145";
			var email = "changjiang@gov.cn";
			var mobilePhone = "13794961693";
			if(913201187245953450==userId){
				companyId = "91320120";
				proposer = "王五";
				contactAddr = "高淳县";
				telePhone = "60212145";
				email = "gao@gov.cn";
				mobilePhone = "13794961693";
			}else if(000000000000000000==userId){
				companyId = "91320122";
				proposer = "刘民";
				contactAddr = "东莞";
				telePhone = "60212145";
				email = "gao@gov.cn";
				mobilePhone = "13794961693";
			}
			
			
			$.ajax({
				  type: 'POST',
				  async:false,
				  url: '../user/login',
				  contentType : 'application/json',
				  data:JSON.stringify({"companyId":companyId,"company":$(".selectpicker").find("option:selected").text(),"proposerId":$(".selectpicker").val(),"proposer":proposer,"contactAddr":contactAddr,"telePhone":telePhone,"mobilePhone":mobilePhone,"email":email,"userId":$(".selectpicker").val(),"userName":$(".selectpicker").find("option:selected").text()}),
				  dataType: 'json',
				  success: function(data){
					  console.log(data);
					  if(1==data.result){
							$('#logined').css("display","block");
							$('#login').css("display","none");
							$('#logined dd:eq(0)').text(data.datas.userName+"欢迎登陆");
						}else{
							$('#logined').css("display","none");
							$('#login').css("display","block");
						}						
				  }
			})
		});
						
 })
 
